<template>
    <div class="house">
        <!-- 导航栏 -->
        <van-nav-bar title="找房子" left-text="返回" right-text="首页" left-arrow @click-left="onClickLeft"
            @click-right="onClickRight" />
        <div class="main">
            <van-search v-model="value" placeholder="你想住哪儿?" @search="onSearch"/>
            <img src="../../assets/QQ截图20221012233241.png" alt="">
            <!-- 筛选框 吸顶 -->

            <div class="house_list">
                <div class="house_each" @click="gotoDetail(item.id)" v-for="item in houseList.rows" :key="item.id">
                    <div class="img">
                        <img :src="'http://218.7.112.123:10001/'+item.pic">
                    </div>
                    <div class="house_des">
                        <div class="house_name">
                            <span>{{item.houseType
                            }}</span>|
                            <span>{{item.sourceName}}</span>
                        </div>
                        <div class="house_area">
                            <span>{{item.areaSize}}m<sup style="font-size:12px">2</sup>|
                                {{item.address}}</span>

                        </div>
                        <div class="house_price">
                            <span>{{item.price}}</span>
                        </div>
                    </div>

                </div>
            </div>
        </div>

    </div>
</template>

<script>
// import nav from "@/mixin/nav";
import { houseList } from "@/service/house/houseservice"
export default {
    // mixins: [nav],
    data() {
        return {
            value: "",

            houseList: [],
        }
    },

    async created() {
        let { data } = await houseList()
        this.houseList = data;
        console.log(JSON.parse(JSON.stringify(data.rows)));
    },
    methods: {
        onSearch() {
            //   Toast(val);
            // alert(val)
            this.$dialog.alert({
            message: "此功能暂未开放,敬请期待!"
          }).then(() => {

          })
        },
        onCancel() {
            //   Toast('取消');
        },
        onClickLeft() {
            this.$router.go(-1)
        },
        onClickRight() {
            this.$router.push("/")
        },
        gotoDetail(id) {
            this.$router.push("/housedetail/" + id)
            //   alert("点击的商品"+id)
        },

        


    }
}
</script>

<style lang="scss" scoped>
.house {
    padding-bottom: 50px !important;
}

.van-nav-bar {
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    // margin-bottom: 46px;
    z-index: 10000;
}

.main {
    height: 1000px;
    margin-top: 46px;
    // padding-bottom: 100px;
    margin-bottom: 50px;

    img {
        display: block;
        width: 100%;
        font-size: 0;
    }

    .house_list {
        margin-top: 10px;
        width: 100%;
        padding: 0 10px;
        padding-bottom: 50px;

        .house_each {
            width: 100%;
            height: 100px;
            padding: 5px 8px;
            display: flex;
            box-sizing: border-box;
            margin-bottom: 5px;
            justify-content: space-between;
            border-bottom: 1px solid rgb(206, 206, 206);

            .img {
                width: 35%;
                height: 100%;

                img {
                    width: 100%;
                    height: 100%;
                }
            }

            .house_des {
                div {
                    margin-top: 5px;
                }

                width: 60%;

                .house_name {
                    span {
                        font-size: 18px;
                    }

                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;

                }

                .house_area {
                    span {
                        color: rgb(152, 151, 151);
                    }
                }

                .house_price {
                    span {
                        color: rgb(255, 85, 46);
                        font-size: 18px;
                        font-weight: 700;
                        font-family: "黑体";
                    }

                }
            }

            .house_area {
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
            }
        }
    }
}
</style>